//try and replicate figure 17 in Seshadri and Lee (2018)
use "$data/Lee_Seshadri/cds_panel", clear

//generate acitve/passive time from mom and dad
gen dad_time1 = .
gen dad_time2 = .
gen mom_time1 = .
gen mom_time2 = .

replace dad_time1 = headtime if head_sex == 1
replace dad_time2 = headtime2 if head_sex == 1

replace mom_time1 = wifetime if head_sex == 1
replace mom_time2 = wifetime2 if head_sex == 1

replace mom_time1 = headtime if head_sex == 2
replace mom_time2 = headtime2 if head_sex == 2

su dad_time1 [w = cds_weight]
su mom_time1 [w = cds_weight]

//correlation between head/wife time and hours investments
gen head_wage = head_labinc / (head_annual)
gen wife_wage = wife_labinc / (wife_annual)

corr head_wage dad_time1
corr wife_wage mom_time1


//average inputs
gen total_time = .
replace total_time = mom_time1 if mom_time1!=. & dad_time1 == .
replace total_time = dad_time1 if dad_time1!=. & mom_time1 == .
replace total_time = (dad_time1 + mom_time1)/2 if mom_time1!=. & dad_time1!=.
replace total_time = total_time / 168
su total_time [w = cds_weight] //more or less a replication
//local time = `r(mean)'

//study differences based on marreid vs non=married
replace total_time = mom_time1 + dad_time1 if mom_time1!=. & dad_time1!=. //now the sum instead of average input
replace total_time = total_time / 168 if mom_time1!=. & dad_time1!=.

set seed 1234
qui{
	forval i = 1/1000{
		preserve
	
		if mod(`i', 20)==0{
			noi di as result "`i'"
		}
		
		bsample
		su total_time [w = cds_weight] //more or less a replication
		local time = `r(mean)'
		clear
		set obs 1
		gen moment = `time'
		save "$temp/boot/cds_time_boot_`i'", replace		
		restore
	}
}

clear
forval i = 1/1000{
	append using "$temp/boot/cds_time_boot_`i'"
}
export delimited "$dir/Model/boot/cds_time_boot_sample.csv", novarn replace



 
//end of dofile